package com.sugon.consts;

import cn.hutool.core.map.MapUtil;

import java.util.Map;

/**
 * 工厂类别枚举类
 * 0设备 1备件 2模具
 *
 * @Author YuXD
 * @Version 1.0
 * @since 2022/6/11
 */
public enum FactoryTypeEnum {

    DEVICE(0, "设备供应商"),
    SPARE_PART(1, "备件供应商"),
    MOLD(2, "模具备件供应商");

    Integer value;

    String name;

    FactoryTypeEnum(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    public Integer getValue() {
        return value;
    }

    public String getName() {
        return name;
    }

    /**
     * 返回已value为key，name为值的map
     *
     * @return
     */
    public static Map<Integer, String> toValueNameMap() {
        Map<Integer, String> result = MapUtil.newHashMap();
        FactoryTypeEnum[] typeEnums = values();
        for (FactoryTypeEnum typeEnum : typeEnums) {
            result.put(typeEnum.getValue(), typeEnum.getName());
        }
        return result;
    }

    /**
     * 返回已name为key，value为值的map
     *
     * @return
     */
    public static Map<String, Integer> toNameValueMap() {
        Map<String, Integer> result = MapUtil.newHashMap();
        FactoryTypeEnum[] typeEnums = values();
        for (FactoryTypeEnum typeEnum : typeEnums) {
            result.put(typeEnum.getName(), typeEnum.getValue());
        }
        return result;
    }

}
